// JavaScript Document
$(document).ready(function(){

	
	$.ajax({
  		type: "post",
 		url: "hmk/findExpertArea_findAll.action",
  		success:function(data){
  			$.each(data.expareaList,function(i,n){
  				$("<option value="+n.expareaId+">"+n.expareaName+"</option>").appendTo('#areaID');
			});
  		}
	});
	
	$.ajax({
  		type: "post",
 		url: "hmk/getWukuType_getWukuType.action",
  		success:function(data){
  			$.each(data.typeList,function(i,n){
  				$("<option value="+n.tpyeId+">"+n.tpyeName+"</option>").appendTo('#typeID');
			});
  		}
	});
	
	
	$('#ADD_EXP_TOP').click(function(){
		$('#mainFrame',window.parent.document).attr('src','/ag/hmk/ExpertAdd.jsp');
	});
	
	
	$('#FIND_EXP_TOP').click(function(){	
		$('#mainFrame',window.parent.document).attr('src','/ag/hmk/ExpertMain.jsp');
		/*	
		var typeID=$('#typeID  option:selected').val();
		var expName=$('#expNameID').val();
		var areaID=$('#areaID  option:selected').val();
		//var expRusume=$('#expRusumeID').val();
		
		$('#mainFrame',window.parent.document).attr('src','hmk/ExpertMain.jsp');
		$(window.parent.frames["mainFrame"].document).find('#expertBody').empty();	
		$(window.parent.frames["mainFrame"].document).find("#loadingPerson").show();
		$.ajax({
  			type: "post",
 			url: "hmk/findSomeExpert_findExpertList.action",
 			data:{
 				  typeID1:typeID,areaID1:areaID,expName1:expName
 				 },
  			success:showData
		});
		*/
	});
	
	
	function showData(data){
		$(window.parent.frames["mainFrame"].document).find('#expertBody').empty();	
		if(data.pageUtil.list.length==0){
			$(window.parent.frames["mainFrame"].document).find("#loadingPerson").hide();
			$(window.parent.frames["mainFrame"].document).find("#nonePerson").show();
			$(window.parent.frames["mainFrame"].document).find("#total").text(0);
			$(window.parent.frames["mainFrame"].document).find("#page").text(0);
			$(window.parent.frames["mainFrame"].document).find("#pageCount").text(0);
			$(window.parent.frames["mainFrame"].document).find("#maxRow").text(0);
		}else{
			$(window.parent.frames["mainFrame"].document).find("#nonePerson").hide();
		    $(window.parent.frames["mainFrame"].document).find("#loadingPerson").hide();
		    $.each(data.pageUtil.list,function(i,n){
		    	//alert(n.tbType.tpyeName);
				//n.expBirthday
				var sex ="男";
				if(n.expSex=='0') sex="女";
				fillDataToHtml(n.expId,n.tbType.tpyeName,n.tbExpertArea.expareaName,n.expName,
						  sex,n.expMobile,n.expUnit,n.expTitle,n.expPost,data.eventList[i]);
						  
						  
		  	});
		
		$(window.parent.frames["mainFrame"].document).find('#total').text(data.pageUtil.total);
		$(window.parent.frames["mainFrame"].document).find('#page').text(data.pageUtil.page);
		$(window.parent.frames["mainFrame"].document).find('#pageCount').text(Math.ceil(data.pageUtil.total/10));
		$(window.parent.frames["mainFrame"].document).find('#maxRow').text(data.pageUtil.maxRow);
		}
	}
	
	function fillDataToHtml(eid,etype,earea,ename,esex,ephone,eunit,etitle,epost,neventlist){
		//ebirthday.replace(/T/," ")
		var strHtml="<tr>";
		strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=etype+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=earea+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=ename+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=esex+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=ephone+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=eunit+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=etitle+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=epost+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center' class='STYLE2 STYLE1'>";
        strHtml+=neventlist+"</div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center'><img src='hmk/images/037.gif' width='9' height='9' /><span class='STYLE1'> [</span><a style='cursor:pointer' onclick='getExpertDetail(this)'>详情</a>";
			strHtml+="<span  style='display:none'>";
	    	strHtml+=eid;
	    	strHtml+="</span>";        
        strHtml+="<span class='STYLE1'>]</span></div></td>";
        strHtml+="<td height='30px' bgcolor='#FFFFFF'><div align='center'><span class='STYLE2'><img src='hmk/images/010.gif' width='9' height='9' /> </span><span class='STYLE1'>[</span><a  style='cursor:pointer' onclick='delExpert(this)'>删除</a>";
        	strHtml+="<span  style='display:none'>";
	    	strHtml+=eid;
	    	strHtml+="</span>";
        strHtml+="<span class='STYLE1'>]</span></div></td>"
        strHtml+="</tr>";
        
        $(window.parent.frames["mainFrame"].document).find('#expertBody').append(strHtml);
        //$(window.parent.frames["mainFrame"].document).find('#expertBody').append(strHtml);
	}

	
});